package com.atguigu.blog.service.impl;

import com.atguigu.blog.mapper.ArticleMapper;
import com.atguigu.blog.pojo.Article;
import com.atguigu.blog.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @ClassName ArticleServiceImpl
 * @Description TODO
 * @Author 孤妤
 * @Date 2023/11/24 17:00
 */
@Service
@Transactional
public class ArticleServiceImpl implements ArticleService {
    @Autowired
    private ArticleMapper articleMapper;
    @Override
    @Transactional(readOnly = true)
    public List<Article> showAll(Article article) {
        return articleMapper.selectAll(article);
    }

    @Override
    @Transactional(readOnly = true)
    public Article showAllById(Integer id) {
        return articleMapper.selectAllById(id);
    }

    @Override
    @Transactional(readOnly = true)
    public List<Article> showAllByUid(Integer uid) {
        return articleMapper.selectAllByUid(uid);
    }

    @Override
    public Integer add(Article article) {
        return articleMapper.insert(article);
    }

    @Override
    public Integer remove(Integer id) {
        return articleMapper.delete(id);
    }

    @Override
    public Integer change(Article article) {
        return articleMapper.update(article);
    }
}